package tripplanner1;
import java.util.*;
public class WichitaToDartmouth {
private static final double AVGFUELPRICEPERGALLON= 1.89;
public static void main(String args[])
{
//array to store the distances through city
	double[] city = new double[100];
//array to store the distances on highway
	double[] highway = new double[100];
	city[0]= 3.3;
	city[1]= 0.05;
	city[2]= 0.2;
	city[3]= 7.8;
	city[4]= 3.2;
	city[5]= 1.0;
	city[6]= 0.7;
	city[7]= 0.8;
	city[8]= 0.8;
	city[9]= 0.4;
	city[10]= 2.2;
	city[11]= 2.3;
	city[12]= 0.6;
	city[13]= 0.8;
	city[14]= 10.5;
	highway[0] = 23.2;
	highway[1] = 56.2;
	highway[2] = 50.3;
	highway[3] = 6.7;
	highway[4] = 50.7;
	highway[5] = 46.2;
	highway[6] = 104.2;
	highway[7] = 152.5;
	highway[8] = 52.6;
	highway[9] = 306.2;
	highway[10] = 441.0;
	highway[11] = 19.2;
	highway[12] = 5.5;
	highway[13] = 17.1;
	highway[14] = 18.7;
	highway[15] = 25.2;
	highway[16] = 30.6;
	highway[17] = 9.4;
	highway[18] = 0.4;
	highway[19] = 3.0;
	highway[20] = 5.3;
	int i=0;
	double c=0;
	double total=0;
	for(i=0;i<=16;i++)
	{
		c= city[i];
	//	System.out.println(c);
		total = total + city[i];
		
	}
	System.out.print("The total distance through city is :");
	System.out.print(total);
	System.out.println("");
	int j=0;
	double highwaytotal=0;
	double h=0;
	for(j=0;j<25;j++)
	{
		h=highway[j];
			//	System.out.println(h);
		highwaytotal = highwaytotal + highway[j];
	}
	
	System.out.print("The distance covered through highway is:");
	System.out.println(highwaytotal);
	
	double totalmiles =0;
	totalmiles = total + highwaytotal;
	System.out.println("");
	//To calculate the total miles travelled
	System.out.println("THE MILES DRIVEN FOR THE TRIP");
	System.out.print("Total miles covered including city miles and highway miles is :");
	System.out.println(totalmiles);
	System.out.println("");
	
//array for car model
	String[] carmodel = new String[6];
	carmodel[0] = "ChevroletSpark" ;
	carmodel[1] = "ChevroletCruze";
	carmodel[2] = "ChevroletSonic";
	carmodel[3] = "ChevroletCamaro" ;
	carmodel[4] = "ChevroletSuburban1500";
	carmodel[5] = "ChevroletSuburban2500";
	double[] citympg = new double[6];
	citympg[0]=28;
	citympg[1]=22;
	citympg[2]=25;
	citympg[3]=19;
	citympg[4]=13;
	citympg[5]=10;
	double[] highwaympg = new double[6];
	highwaympg[0]=36;
	highwaympg[1]=35;
	highwaympg[2]=35;
	highwaympg[3]=28;
	highwaympg[4]=18;
	highwaympg[5]=15;
	double[] price = new double[6];
//array for storing total gallons for each car
	double[] gallons = new double[6];
	int g=0;
	double totalgal = 0;
	double cm =0;
	double citygal=0;
	double hm = 0;
	double highwaygal =0 ;
	double totalprice =0;
	double p=0;
	//array for storing the tank size of the cars
	double[] tanksize= new double[6];
	double[] fp = new double[6];
	tanksize[0]= 10.5;
	tanksize[1]= 12.5;
	tanksize[2]= 12;
	tanksize[3]= 13;
	tanksize[4]= 33;
	tanksize[5]= 36;
	int t=0;
	int f=0;
	double refill=0;
	double fuelprice=0;
	double[] tp= new double[6];
	int k=0;
	for(k=0;k<6;k++){
		System.out.println("");
		System.out.print("For ");
		System.out.print(carmodel[k]);
		System.out.println("");
		System.out.print("City gallons :");
		cm = citympg[k];
		System.out.print(cm);	
		citygal = totalmiles/cm;
		System.out.print(citygal);
		System.out.println("");
		System.out.print("Highway gallons:");
		hm = highwaympg[k];
		highwaygal = totalmiles/hm;
		System.out.println(highwaygal);
		totalgal = citygal + highwaygal;
		System.out.print("The total gallons:");
		System.out.print(totalgal);
		gallons[k] = totalgal ;
		refill = gallons[k] / tanksize[k];
		int ref = (int)refill;
		System.out.println("");
		System.out.print("The number of refills" );
		System.out.print(" for " + carmodel[k] + " is ");
		System.out.println(ref);
		System.out.print("total price based on fuel refill is :");
		fuelprice = ref * AVGFUELPRICEPERGALLON ; 
		System.out.print(fuelprice);
		System.out.println("");
		fp[k]= fuelprice;
		totalprice = totalgal * AVGFUELPRICEPERGALLON ;
		System.out.print("Cost to get to destination based on fuel for " + carmodel[k] + " is ");
		System.out.println(totalprice);
		tp[k] = totalprice;
	}
	//to find out the vehicles with highest and lowest prices of fuel added			
		double lowfp = fp[0];
		double highfp = fp[0];
		String cwlf = carmodel[0];
		String cwhf = carmodel[0];
		int n=0;
		for(f=0;f<fp.length;f++){
			if(fp[f]>highfp)
				highfp = fp[f];
			else if(fp[f] < lowfp)
				lowfp = fp[f];
		}
			System.out.println("");
			System.out.println("VEHICLES WITH HIGHEST AND LOWEST PRICES BASED ON FUEL ADDED");
			System.out.print("The highest cost based on the fuel added is :" );
			System.out.println(highfp);
			System.out.print("The lowest cost based on the fuel added is :");
			System.out.println(lowfp);
			
			for (n=0;n<6;n++){
				if (lowfp == fp[n]){
					cwlf = carmodel[n];
					//System.out.println("");
				
					
					System.out.println("The vehicle with lowest price based on fuel added to tank is :" +cwlf);
				} 
				if (highfp == fp[n]){
					cwhf = carmodel[n];
					System.out.println("The vehicle with highest price based on fuel added to tank is :" +cwhf);
				}
				}
			
			
			for(t=0;t<6;t++)
			{
		//	System.out.print("The total price for travelling in " +carmodel[t] +" is");
			price[t]=tp[t] + fp[t];
			p = price[t];
		//	System.out.print(p);
			//System.out.println(p);
			
			}
//to calculate the highest and lowest prices of vehicles
	double max = price[0];
	double min = price[0];
	int l=0;
	for(l=0;l<price.length;l++){
	if(price[l]> max)
		max = price[l];
	else if(price[l]<min)
		min = price[l];
}
//To print the vehicles names with highest and lowest prices
	System.out.println("");
	System.out.println("VEHICLE WITH HIGHEST AND LOWEST PRICES BASED ON FUEL USED");
	System.out.println("The highest price is:" +max);
	System.out.println("The lowest price is:" +min); 
	int m=0;
	String cwhp = carmodel[0];
	String cwlp = carmodel[0];
	for (m=0;m<6;m++){
	if (max == price[m]){
		cwhp = carmodel[m];
	System.out.println("The vehicle with highest price is : " +cwhp);
	System.out.println("The vehicle with lowest price is : " +cwlp);
	}

}

}}
